package com.ltu.controller.customize;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ltu.model.request.base.BaseFilterPageReq;
import com.ltu.model.request.base.BaseIdReq;
import com.ltu.model.response.base.CodeDataResp;
import com.ltu.service.impl.BaseServiceImpl;
import com.ltu.util.common.MpPageUtil;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.ltu.config.shiro.ShiroUtil;
import com.ltu.config.shiro.dto.UserDto;
import com.ltu.constant.CommonConstant;
import com.ltu.domain.mp_entity.customize.WalletRecordEntity;
import com.ltu.mapper.customize.WalletRecordMapper;


/**
 * <p>
 * 钱包动态记录 前端控制器
 * </p>
 *
 * @author 若尘
 * @since 2024-03-16
 */
@RestController

@RequestMapping("/WalletRecord")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags= "钱包动态记录")
public class WalletRecordController extends BaseServiceImpl<WalletRecordMapper, WalletRecordEntity>{
    @ApiOperation(value="获取分页列表")
    @RequestMapping(value="/getMePage", method= RequestMethod.POST)
    public CodeDataResp<Page<WalletRecordEntity>> getMePage(@RequestBody  BaseFilterPageReq<WalletRecordEntity> req ) {
    	Page<WalletRecordEntity> page = MpPageUtil.getCommonPage(req.getPageReq());
		QueryWrapper<WalletRecordEntity>  t=new QueryWrapper<WalletRecordEntity>();
		UserDto user = ShiroUtil.getPrincipalUser();
		if(null != req.getKeyWords() && req.getKeyWords().size() > 0) 
			t.apply(getLikeStr(req.getKeyWords(),""));
		 t.setEntity(req.getEntityParam());
    	Page<WalletRecordEntity>	 result= super.page(page, t);
		return CodeDataResp.valueOfSuccess(result);
    }
    
    @ApiOperation(value="获取列表")
    @RequestMapping(value="/getList", method= RequestMethod.POST)
    public CodeDataResp<List<WalletRecordEntity>> getList(@RequestBody  BaseFilterPageReq<WalletRecordEntity> req ) {
		QueryWrapper<WalletRecordEntity>  t=new QueryWrapper<WalletRecordEntity>();
		UserDto user = ShiroUtil.getPrincipalUser();
		
		if(null != req.getKeyWords() && req.getKeyWords().size() > 0) 
			t.apply(getLikeStr(req.getKeyWords(),""));
		 t.setEntity(req.getEntityParam());
		 List<WalletRecordEntity>	 result= super.list( t);
		 return CodeDataResp.valueOfSuccess(result);
    }

    @ApiOperation(value="新增/保存")
    @RequestMapping(value="/edit", method= RequestMethod.POST)
    public CodeDataResp edit(@RequestBody WalletRecordEntity req) {
        return super.edit(req);
    }
    
//    @ApiOperation(value="批量修改数据")
//    @RequestMapping(value="/edits", method= RequestMethod.POST)
    public CodeDataResp edits(@RequestBody List<WalletRecordEntity> reqs) {
    	super.saveOrUpdateBatch(reqs);
    	return   CodeDataResp.valueOfSuccessEmptyData();
    }
    
    
    	@ApiOperation(value="获取详情")
    @RequestMapping(value="/getDetail/{id}", method= RequestMethod.GET)
    public CodeDataResp<WalletRecordEntity> getDetail(@PathVariable String id) {
 		BaseIdReq req=new BaseIdReq(id);
        return super.getDetail(req);
    }
    

 	 @ApiOperation(value="删除")
     @RequestMapping(value="/remove/{id}", method= RequestMethod.GET)
     public CodeDataResp remove(@PathVariable String id) {
     	BaseIdReq req=new BaseIdReq(id);
     	return super.remove(req);
     }
     
 //   @ApiOperation(value="删除s")
//    @RequestMapping(value="/removes", method= RequestMethod.POST)
    public CodeDataResp removes(@RequestBody List<Integer> ids) {
    		super.removeByIds(ids);
        return CodeDataResp.valueOfSuccessEmptyData();
    }

}

